//
//  ScrollView.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/7/3.
//

import SwiftUI

struct ScrollViewStudy: View {
    var body: some View {
        VStack(spacing: 10) {
            HStack{
                VStack(alignment: .leading){
                    Text("欢迎学习")
                        .foregroundStyle(Color.black)
                        .font(.system(size: 25, weight: .bold))
                    
                    Text("我的SwiftUI课程")
                        .foregroundStyle(Color.black)
                        .font(.system(size: 25, weight: .bold))
                }
                Spacer()
            }.padding()
            
            ScrollView(showsIndicators: false){
                VStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: 30){
                    MyCardView()
                    MyCardView()
                    MyCardView()
                    MyCardView()
                    MyCardView()
                }
            }
            
           
            Spacer()
            
            
        }
            
        
    }
}

#Preview {
    ScrollViewStudy()
}

struct MyCardView: View {
    var body: some View {
        VStack {
            HStack {
                VStack(alignment: .leading, spacing: 10) {
                    Text("iOS开发")
                        .foregroundStyle(LinearGradient(colors: [.purple,.blue], startPoint: .leading, endPoint: .trailing))
                        .font(.system(size: 20, weight: .bold))
                    Text("Text教程")
                        .foregroundStyle(LinearGradient(colors: [.purple,.blue], startPoint: .leading, endPoint: .trailing))
                        .font(.system(size: 25, weight: .bold))
                }
                Spacer()
            }
            Spacer()
            
            HStack {
                Text("Text教程")
                    .foregroundStyle(.white)
                    .font(.system(size: 14, weight: .regular))
                    .padding(5)
                    .background(.blue)
                    .cornerRadius(5)
                
                Spacer()
            }
        }
        .frame(width: .infinity,height: 150)
        .padding(20)
        .background(.white)
        .clipShape(RoundedRectangle(cornerSize: CGSize(width: 10, height: 10)))
        .shadow(color: .gray, radius: 5, x: 0.0, y: 5)
        .overlay {
            Image("001", bundle: nil)
                .resizable()
                .scaledToFill()
                .frame(width: 100,height: 100)
                .background(.blue)
                .clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
                .offset(x: 135,y: 70)
        }.padding()
    }
}
